package main;

import maths.*;

public class LJPotential {

Parameters params = new Parameters(1,1,1);
	
	//    							 V(r)   [ (sigma) 12   (sigma) 6]
	//calculates potential using U = ____ = [ (_____)^   - (_____)^ ]
	//								  4e    [ (  r  )	   (  r  )  ] 
public double potential(Particles p, int i, int j){
	
	Vector3d path = new Vector3d(p.getPosition(i));
	path.multiply(-1);
	path.add(new Vector3d(p.getPosition(j)));
	double r = path.length();
	double v = (Math.pow((params.sigma()/r),12) -Math.pow((params.sigma()/r),6));
	
	double potential = v/4*params.epsilon();
	
	return potential;
}


public Vector3d ljForce(Particles p, int i, int j,double potential){
    Vector3d distance = new Vector3d(p.getPosition(i));
    distance.multiply(-1);
    distance.add(new Vector3d(p.getPosition(j)));

Vector3d direction = new Vector3d();
direction.normalize(distance);

double r = distance.length();
double sigmaUponR = params.sigma();
double forceMagnitude = potential/Math.pow(params.sigma(), 2)*(12*Math.pow(sigmaUponR,14)-6*Math.pow(sigmaUponR,8));

direction.multiply(forceMagnitude) ;
return direction;
}
	
}
